package cn.JHai.rbac.domain;

import lombok.Getter;
import lombok.Setter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

@Setter
@Getter
public class Customertracehistory {
    private Long id;

    private Date trace_time;

    private String trace_details;

    private Long trace_type_id;

    private Integer trace_result;

    private Long customer_id;

    private Long input_user_id;

    ///////////
    private SystemDictionaryItem trace_type;

    private Customer customer;

    private Employee input_user;

    private String str_trace_time;

    private String display_trace_result;

    public String getDisplay_trace_result(){
        if(this.trace_result != null){
            //1，2，3
            if(this.trace_result == 1)
                this.display_trace_result = "差";
            else if(this.trace_result == 2)
                this.display_trace_result = "中";
            else
                this.display_trace_result = "优";
        }
        return this.display_trace_result;
    }

    public String getStr_trace_time() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        return this.str_trace_time = sdf.format(this.trace_time);
    }

    public void setStr_trace_time() {

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        str_trace_time = sdf.format(this.trace_time);
        this.str_trace_time = str_trace_time;
    }

    @Override
    public String toString() {
        return "CustomerTraceHistory{" +
                "id=" + id +
                ", trace_time=" + trace_time +
                ", trace_details='" + trace_details + '\'' +
                ", trace_type_id=" + trace_type_id +
                ", trace_result=" + trace_result +
                ", customer_id=" + customer_id +
                ", input_user_id=" + input_user_id +
                '}';
    }
    public void setTrace_time(String trace_time) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd");//设置时间格式
        try {
            Date ts = sdf.parse(trace_time);//转换为Date类型 这里要抛一个异常
            this.trace_time = ts;
        } catch (ParseException e) {
            e.printStackTrace();

        }

    }

}
